package com.news.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.news.common.lang.Result;
import com.news.service.SysNewsService;
import com.news.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.bind.annotation.PostMapping;

import javax.servlet.http.HttpServletRequest;

public class BaseController {

    //文章
    @Autowired
    SysNewsService sysNewsService;

    //用户
    @Autowired
    SysUserService sysUserService;

    //设置默认分页页码
    @Autowired
    HttpServletRequest req;

    public Page getPage(){
        //分页默认值
        int current = ServletRequestUtils.getIntParameter(req,"current",1);
        int size = ServletRequestUtils.getIntParameter(req,"size",10);
        return new Page(current,size);
    }

    //统一退出接口
    @PostMapping("/logout")
    public Result logout(){
        return Result.succ("");
    }
}
